package com.google.code.training_java_basic.basics;

import java.util.Scanner;

/**
 * Class PrimeNumbers searches prime numbers which are smaller or equal to the
 * in-putted from keyboard integer number. 
 */
	 
public class PrimeNumbers {

	public static void main(String[] args) {

		int maxNumber;
		int divCounter;
			
		Scanner scanner = new Scanner(System.in);
		System.out.print("Enter max number: ");
		maxNumber = scanner.nextInt();
		scanner.close();
		System.out.print("[");

		for (int i = 1; i <= maxNumber; i++) {
			divCounter = 0;
			for (int j = 1; j <= i; j++) {
				if (i % j == 0) {
					divCounter++;
				}
			}
			if (divCounter <= 2) {
				System.out.print(i + " ");
			}
		}

		System.out.println("]");
		
	}
}